using System.IO;
using System.Threading;

namespace winsw
{
	public abstract class SimpleLogAppender : AbstractFileLogAppender
	{
		private FileMode fileMode;

		private string outputLogFileName;

		private string errorLogFileName;

		public string OutputLogFileName => outputLogFileName;

		public string ErrorLogFileName => errorLogFileName;

		public SimpleLogAppender(string logDirectory, string baseName, FileMode fileMode)
			: base(logDirectory, baseName)
		{
			this.fileMode = fileMode;
			outputLogFileName = base.BaseLogFileName + ".out.log";
			errorLogFileName = base.BaseLogFileName + ".err.log";
		}

		public override void log(Stream outputStream, Stream errorStream)
		{
			new Thread((ThreadStart)delegate
			{
				CopyStream(outputStream, new FileStream(outputLogFileName, fileMode));
			}).Start();
			new Thread((ThreadStart)delegate
			{
				CopyStream(errorStream, new FileStream(errorLogFileName, fileMode));
			}).Start();
		}
	}
}
